//
//  TCClothesCollectionViewCell.m
//  Project_B
//
//  Created by dllo on 15/11/28.
//  Copyright © 2015年 张闯. All rights reserved.
//

#import "TCClothesCollectionViewCell.h"
#import "UIImageView+WebCache.h"
#define WIDTH [[UIScreen mainScreen] bounds].size.width / 375
#define HEIGHT [[UIScreen mainScreen] bounds].size.height / 667
@interface TCClothesCollectionViewCell ()
@property (nonatomic, strong)UIImageView *imageView;
@property (nonatomic, strong)UILabel *titlelabel;
@property (nonatomic, strong)UILabel *scorelabel;
@end


@implementation TCClothesCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        self.imageView = [[UIImageView alloc]init];
        [self.contentView addSubview:self.imageView];
    
        self.imageView.layer.borderWidth = 1;
        self.imageView.layer.borderColor = [UIColor colorWithRed:60.0 / 255 green:149.0 / 255 blue:58.0 / 255 alpha:1].CGColor;
        
        self.titlelabel = [[UILabel alloc]init];
        self.titlelabel.layer.borderWidth = 1;
        self.titlelabel.layer.borderColor = [UIColor colorWithRed:60.0 / 255 green:149.0 / 255 blue:58.0 / 255 alpha:1].CGColor;
        [self.titlelabel setFont:[UIFont systemFontOfSize:14]];
        self.titlelabel.textColor = [UIColor grayColor];
        [self.contentView addSubview:self.titlelabel];
        self.titlelabel.numberOfLines = 0;
        
        self.scorelabel = [[UILabel alloc]init];
        self.scorelabel.layer.borderWidth = 1;
        self.scorelabel.layer.borderColor = [UIColor colorWithRed:60.0 / 255 green:149.0 / 255 blue:58.0 / 255 alpha:1].CGColor;
        [self.contentView addSubview:self.scorelabel];
        self.scorelabel.textColor = [UIColor grayColor];
        [self.scorelabel setFont:[UIFont systemFontOfSize:13]];
        self.scorelabel.textAlignment = NSTextAlignmentCenter;
    }
    return self;
}
- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    [super applyLayoutAttributes:layoutAttributes];
    self.imageView.frame = CGRectMake(0, 0, (355/2-20)*WIDTH, 180*HEIGHT);
    self.titlelabel.frame = CGRectMake(0, 181*HEIGHT, self.imageView.frame.size.width, 60*HEIGHT);
    self.scorelabel.frame = CGRectMake(0, 242*HEIGHT, self.imageView.frame.size.width, 40*HEIGHT);
}
- (void)setTemp:(Clothes *)temp
{
    if (_temp != temp) {
        _temp = temp;
    }
    [self.imageView sd_setImageWithURL:[NSURL URLWithString:temp.thumb] placeholderImage:[UIImage imageNamed:@"zhanwei.png"]];
    self.titlelabel.text = temp.title;
    self.scorelabel.text = [NSString stringWithFormat:@"评分:%@",temp.score];
}
@end
